package com.hzdesk.media.matvector.koreabatch.client.my_paperless.utils;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.base.BaseAdapter;

/**
 * Created by Administrator on 2018/8/7.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 *
 *
 * RecyclerView 工具类
 */

public class RecyclerViewUtils {
    private String TAG = RecyclerViewUtils.class.getSimpleName();
    private final int VERTICAL = 0;                                                                 //垂直
    private final int LEVE = 1;                                                                     //水平

    /**
     * @desc 初始化RecyclerView
     * */
    public  void initView(RecyclerView myRecyclerView, int type, Context mContext,RecyclerView.Adapter myBaseAdapter){
        LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);//设置布局管理器
        if(type == VERTICAL){
            layoutManager.setOrientation(OrientationHelper.VERTICAL);
        }else{
            layoutManager.setOrientation(OrientationHelper.HORIZONTAL);
        }
        if(myRecyclerView != null){
            myRecyclerView.setLayoutManager(layoutManager); //设置为垂直布局，这也是默认的
            if(myBaseAdapter != null){
                myRecyclerView.setAdapter(myBaseAdapter);
            }else{
                Log.e(TAG, "initView: 传入的RecyclerView 或者 myBaseAdapter 为 null 请检查 " );
            }
        }else{
            Log.e(TAG, "initView: 传入的RecyclerView为null 所以显示为空白  "+myRecyclerView );
        }
    }
}
